<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var arr = [1, 2, 3, 6, 5];
    var max = arr[0], min = arr[0];
    var maxindex = 0;
    var minindex = 0;
    for (var i = 0; i < arr.length; i++) {
        if (arr[i] > max) {
            max = arr[i];
            maxindex = i;
        } else if (arr[i] < min) {
            min = arr[i];
            minindex = i;
        }
    }
    console.log("最大值为：" + max + "位置为：" + maxindex);
    console.log("最小值为：" + min + "位置为：" + minindex);

</script>
</html>